package cn.com.thinvent.dispatch.web.controller;

import cn.com.thinvent.dispatch.entity.ModelFiletag;
import cn.com.thinvent.dispatch.entity.response.PagedGridResult;
import cn.com.thinvent.dispatch.entity.response.ReturnModel;
import cn.com.thinvent.dispatch.service.biz.ModelFiletagService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 非结构化数据源标签controller
 */
@Api(description = "modelFiletag模块")
@Controller
@RequestMapping("/modelFiletag")
@CrossOrigin(origins = "*")
@ResponseBody
public class ModelFiletagController {

    @Autowired
    private ModelFiletagService modelFiletagService;

    /**
     * 执行目标列表
     * @param modelFiletag
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public ReturnModel list(ModelFiletag modelFiletag,
                            @RequestParam("pageNum") Integer pageNum,
                            @RequestParam("pageSize") Integer pageSize) {
        PagedGridResult<ModelFiletag> list = modelFiletagService.list(modelFiletag, pageNum, pageSize);
        return new ReturnModel(200, list, "");
    }

    /**
     * 新增或修改目标对象
     * @param modelFiletag
     * @return
     */
    @PostMapping("/saveOrUpdate")
    @ResponseBody
    public ReturnModel saveOrUpdate(@RequestBody ModelFiletag modelFiletag) {
        ModelFiletag target = modelFiletagService.saveOrUpdate(modelFiletag);
        return new ReturnModel(200, target, "");
    }

    /**
     * 删除执行目标条件
     * @param modelFiletag
     * @return
     */
    @PostMapping("/delete")
    @ResponseBody
    public ReturnModel delete(@RequestBody ModelFiletag modelFiletag) {
        Integer delete = modelFiletagService.delete(modelFiletag.getId());
        return new ReturnModel(200, delete, "");
    }

}
